Programming With QuickTime VR 2.1

Previous | Overview | Contents | Next

Drawing in the Prescreen Buffer

The QuickTime VR Manager allows you to define a prescreen buffer imaging completion procedure that is called whenever QuickTime VR finishes drawing a panorama image in the prescreen buffer. Typically, your completion procedure will add graphical elements to the image before the buffer is copied to the screen. For instance, a flight simulator could overlay a heads-up display containing information about the aircraft (its altitude, velocity, and so forth).

You install a prescreen buffer imaging completion procedure by passing its address to the QTVRSetPrescreenImagingCompleteProc function:

theErr = QTVRSetPrescreenImagingCompleteProc(theInstance,
        NewQTVRImagingCompleteProc(MyImagingCompleteProc),
        (SInt32)&theData, 0);

Listing 11 defines a simple completion routine that overlays a picture onto the screen image.

Listing 11 Overlaying images in the prescreen buffer

pascal OSErr MyImagingCompleteProc (QTVRInstance, MyDataPtr theDataPtr)
{
    if (theDataPtr->hasLogoPict) {
        GWorldPtr   theOffscreenGWorld;
        GDHandle    theGD;
        Rect        gwRect;
        Rect        picRect;

        // The current graphics world is set to the prescreen buffer.
        GetGWorld (&theOffscreenGWorld, &theGD);
        gwRect = (*(theOffscreenGWorld->portPixMap))->bounds;

        picRect = (*(theDataPtr->logoPict))->picFrame;
        OffsetRect (&picRect, -picRect.left, -picRect.top);
        OffsetRect (&picRect, gwRect.right - (picRect.right + 8),
                gwRect.bottom - (picRect.bottom + 8));
        // Draw logo in lower right corner
        DrawPicture (theDataPtr->logoPict, &picRect);
    }
    return noErr;
}

On entry to the prescreen buffer imaging completion routine, the current graphics world is set to QuickTime VR's prescreen buffer. The MyImagingCompleteProc function defined in Listing 11 retrieves the dimensions of that buffer and then draws a picture in the lower right corner of that buffer.


© 1997 Apple Computer, Inc.

Previous | Overview | Contents | Next